package com.shop.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

//多对一
@Entity
@Table(name="emp")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Emp {
	private Integer id;
	private String ename;
	private String job;
	private Dept dept;//映射外键列deptNo
	public Emp() {
		super();
	}
	public Emp(Integer id, String ename, String job, Dept dept) {
		super();
		this.id = id;
		this.ename = ename;
		this.job = job;
		this.dept = dept;
	}
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column
	public String getEname() {
		return ename;
	}
	public void setEname(String ename) {
		this.ename = ename;
	}
	@Column
	public String getJob() {
		return job;
	}
	public void setJob(String job) {
		this.job = job;
	}
	@ManyToOne
	@JoinColumn(name="deptNo")
	public Dept getDept() {
		return dept;
	}
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	@Override
	public String toString() {
		return "Emp [id=" + id + ", ename=" + ename + ", job=" + job
				+ ", dept=" + dept + "]";
	}
	
	
}
